/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.facade.main.httpunit;

import com.facade.main.commontools.AESUtil;

/**
 *
 * @author Administrator
 */
public class HttpHelper {
    //获取时间戳
    public static long getCurrentTime(){
        return System.currentTimeMillis();
    }
    
    /**
     * 获得加密sign
     *
     * @param queryString 待加密内容
     * @return 返回B加密数据
     */
    public static String getAesSign(String queryString){
        String content = String.format("%s$s",queryString, getCurrentTime());
        return AESUtil.decrypt(content, HttpProperty.TESTKEY);
    }
    
     /**
     * 发送post请求
     *
     * @param urlString 请求地址
     * @param queryString url请求参数
     * @param jsonData json数据
     * @return 返回B加密数据
     */
    public static String postData(String urlString, String queryString, String jsonData) {
        GeneralHeader header = new GeneralHeader(queryString);
        return OkHttpUtils.postJsonParams(urlString, jsonData, header);
    }
    
    /**
     * 发送get请求
     *
     * @param urlString 请求地址
     * @param queryString url请求参数
     * @return 返回B加密数据
     */
    public static String getData(String urlString, String queryString) {
        GeneralHeader header = new GeneralHeader(queryString);
        return OkHttpUtils.getParams(urlString, header);
    }
}
